package com.liuxing.javaSpringBoot.modules.common.entity;

import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * Created by IntelliJ IDEA.
 * @File Result.java
 * @Auth liuxing
 * @Date 2021/8/19 10:44
 * @Email liuxing997@foxmail.com
 */
public class Result<T> {

    private int status;

    private String message;

    private T data;

    public Result() {
    }

    public Result(int status, String message) {
        this.status = status;
        this.message = message;
    }

    public Result(int status, String message, T data) {
        this.status = status;
        this.message = message;
        this.data = data;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum ResultCode {
        SUCCESS(200),//成功
        FAILED(400),//失败
        UNAUTHORIZED(401),//未认证
        NOT_FOUND(404),//数据接口不存在
        Permission_Denied(403),//没有权限
        INTERNAL_SERVER_ERROR(500),//服务器错误
        User_Does_Not_Exist(10),//用户不存在
        Wrong_Password(11),//密码错误
        Login_Failed(12),//登录失败
        Username_Is_Exist(13),//用户名已被使用
        Username_Is_Available(14);//用户名可用

        public int code;

        ResultCode(int code) {
            this.code = code;
        }
    }
}
